import React, { Component } from 'react';
import classnames from 'classnames';
import PropTypes from 'prop-types';
import './MaskWrapper.less';


export default class MaskWrapper extends Component {

    constructor(props) {
        super(props)
    }

    static defaultProps = {
        show: false
    }

    static propTypes = {
        show: PropTypes.bool,
        closeHandler: PropTypes.func
    }

    handleClose = e => {
        e.stopPropagation()
        e.preventDefault()
        this.props.closeHandler()

    }


    render() {
        let { show, className } = this.props;
        let mask = classnames({
            'mask': true,
            'show': show,
        }, className);
        return (
            <div>
                <div className={mask} onTouchStart={this.handleClose} onClick={this.handleClose} />
                {this.props.children}
            </div>
        )
    }


}